package com.mjh.zhujianju.controller.agency;

import javax.annotation.Resource;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.livew.framework.exception.XTBusinessException;
import com.livew.framework.utils.XTCurrentUser;
import com.mjh.zhujianju.service.base.UserExtendService;
import com.mjh.zhujianju.util.ApiConstant;
import com.mjh.zhujianju.util.JsonResult;
import com.mjh.zhujianju.vo.base.SysUserVO;

@RestController
@RequestMapping("workUser")
public class WorkUserController {

	@Resource
	private UserExtendService userExtendService;
	
	@RequestMapping(value = "/updateUserInfo", method = RequestMethod.POST)
    public ResponseEntity<JsonResult> updateUserInfo (@RequestBody SysUserVO vo){
		JsonResult result = new JsonResult();
		if(vo==null) {
			result.setStatus(ApiConstant.MSG_ERROR);
			result.setResult("参数错误");
			return ResponseEntity.ok(result);
		}
		vo.setId(XTCurrentUser.getCurrentUserId());
		try {
			userExtendService.updateWorkInfo(vo);
		} catch (XTBusinessException e) {
			e.printStackTrace();
			result.setStatus(ApiConstant.MSG_ERROR);
			result.setResult(e.getMessage());
			return ResponseEntity.ok(result);
		}
		result.setStatus(ApiConstant.MSG_SUCCESS);
		System.out.println(vo);
		return ResponseEntity.ok(result);
	}
}
